var app = getApp();
var promise = require('../../utils/request.js');

Page({
  data: {

  },
  formSubmit:function(e){
    console.log(e)
    this.addAccount(e);
  },
  addAccount:function(e){
    var data = e.detail.value;
    data.unionId = wx.getStorageSync('unionId');
    var userInfo = wx.getStorageSync('userInfo');
    if (userInfo) {
      data.nickName = userInfo.nickName;
      data.headImg = userInfo.avatarUrl;
    }
    promise.sendRequest('account/add', 'Post', data, null,1, {
      success:function(data){
        if (data === true) {
          wx.redirectTo({
            url: '../home/home'
          })
        }
      }
    }, {
      fail:function(res){
        console.log(res)
      }
    }, )

  },
  btnBack: function () {
    wx.navigateBack()
  }
})
